{template 'common/header'}
{if $op == "cz"}
<style type="text/css">
    .panel-body > ul{list-style:none;margin: 0px;padding: 0px}
    .panel-body > ul li{display: inline-block}
</style>
<div class="main">
<ul class="nav nav-tabs">
    <li><a href="{php echo url('members/member');}">财务中心</a></li>
    <li><a href="{php echo url('members/buypackage');}">套餐购买</a></li>
    <li><a href="{php echo url('members/buysms');}">短信购买</a></li>
		{if $_W['isfounder']}
    <li><a href="{php echo url('members/record');}">会员消费</a></li>
	<li><a href="{php echo url('members/configs');}">服务配置</a></li>
    <li class="active"><a href="{php echo url('members/test');}">测试服务</a></li>
    {/if}
</ul>
    <div style="width: 100%" >
        <aside>
            <section>
                <div class="panel panel-default">
                    <div class="panel-heading">{$user[username]} 充值记录</div>
                    <div class="panel-body">
                        <table class="table mytable table-striped b-t text-sm">
                            <thead>
                            <tr>
                                <th width="20"></th>
                                <th class="col-sm-1">货币</th>
                                <th class="col-sm-2">订单号</th>
                                <th class="col-sm-2">第三方订单号</th>
                                <th class="col-sm-1">充值金额</th>
                                <th class="col-sm-2">充值时间</th>
                                <th class="col-sm-1">支付方式</th>
                                <th class="col-sm-1">状态</th>
                            </tr>
                            </thead>
                            <tbody>
                            {loop $list $item}
                            <tr>
                                <th width="20"></th>
                                <th class="col-sm-4">{if $item['credittype']=='credit2'}交易币{else}积分{/if}</th>
                                <th>{$item['orderid']}</th>
                                <th>{$item['order_no']}</th>
                                <th class="col-sm-1">{$item['money']}</th>
                                <th>{php echo date('Y-m-d H:i',$item['order_time'])}</th>
                                <th>
                                    {if $item['pay_type'] ==1}
                                    <span class="label label-info">支付宝</span>
                                    {else}
                                    <span class="label label-default">百付宝</span>
                                    {/if}
                                </th>
                                <th>{if $item['status']==1}<span class="label label-success">已付款</span>{else}<span class="label label-warning">待付款</span>{/if}</th>
                            </tr>
                            {/loop}
                            </tbody>
                        </table>
                        {$pager}
                    </div>
                </div>
            </section>
        </aside>
    </div>
</div>
{elseif $op == "xf"}
<style type="text/css">
    .panel-body > ul{list-style:none;margin: 0px;padding: 0px}
    .panel-body > ul li{display: inline-block}
</style>
<div class="main">
<ul class="nav nav-tabs">
    <li><a href="{php echo url('members/member');}">财务中心</a></li>
    <li><a href="{php echo url('members/buypackage');}">套餐购买</a></li>
    <li><a href="{php echo url('members/buysms');}">短信购买</a></li>
		{if $_W['isfounder']}
    <li><a href="{php echo url('members/record');}">会员消费</a></li>
	<li><a href="{php echo url('members/configs');}">服务配置</a></li>
    <li class="active"><a href="{php echo url('members/test');}">测试服务</a></li>
    {/if}
</ul>
    <div style="width: 100%" >
        <aside>
            <section>
                <div class="panel panel-default">
                    <div class="panel-heading">{$user[username]} 消费记录</div>
                    <div class="panel-body">
                        <table class="table mytable table-striped b-t text-sm">
                            <thead>
                            <tr>
                                <th width="20"></th>
                                <th class="col-sm-1">货币</th>
                                <th class="col-sm-2">金额</th>
                                <th>消费原因</th>
                                <th class="col-sm-2">消费时间</th>
                            </tr>
                            </thead>
                            <tbody>
                            {loop $list $item}
                            {if $item['num'] < 0}
                            <tr>
                                <th width="20"></th>
                                <th class="col-sm-4">交易币</th>
                                <th>{$item['num']}</th>
                                <th class="col-sm-1">{php echo htmlspecialchars_decode($item['remark'])}</th>
                                <th>{php echo date('Y-m-d H:i',$item['createtime'])}</th>
                            </tr>
                            {/if}
                            {/loop}
                            </tbody>
                        </table>
                        {$pager}
                    </div>
                </div>
            </section>
        </aside>
    </div>
</div>
{else}
{php $packages = get_AllPackage()}
<style type="text/css">
    .panel-body > ul{list-style:none;margin: 0px;padding: 0px}
    .panel-body > ul li{display: inline-block}
</style>
<div class="main">
   <ul class="nav nav-tabs">
    <li><a href="{php echo url('members/member');}">财务中心</a></li>
    <li><a href="{php echo url('members/buypackage');}">套餐购买</a></li>
    <li><a href="{php echo url('members/buysms');}">短信购买</a></li>
		{if $_W['isfounder']}
    <li><a href="{php echo url('members/record');}">会员消费</a></li>
	<li><a href="{php echo url('members/configs');}">服务配置</a></li>
    <li class="active"><a href="{php echo url('members/test');}">测试服务</a></li>
    {/if}
</ul>
    <div style="width: 100%" >
        <aside>
            <section>
                <div class="panel panel-default">
                    <form action="" class="form-inline" style="width: 90%;margin: 10px" method="post" enctype="multipart/form-data">
                        <div class="form-group">
                            <div class="input-group">
                                <span class="input-group-addon">帐号</span>
                                <input type="text" name="search[username]" class="form-control" placeholder="登录帐号" value="{$search[username]}" style="width: 200px">
                            </div>
                        </div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        <button type="submit" name="submit" class="btn btn-warning" value="查询"> 查 询 </button>
                        <input type="hidden" name="token" value="{$_W['token']}" />
                        <input type="hidden" name="c" value="site"/>
                        <input type="hidden" name="page" value="{$_GPC['page']}"/>
                        <input type="hidden" name="op" value="search"/>
                        <input type="hidden" name="a" value="entry"/>
                    </form>
                </div>
                <div class="panel panel-default">
                    <table class="table table-hover">
                        <thead>
                        <tr>
                            <th style="width: 5%;text-align: center">#</th>
                            <th>用户名</th>
                            <th>注册时间</th>
                            <th style="width: 20%">当前余额</th>
                            <th style="width: 30%">操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        {loop $list $item}
                        <tr>
                            <td style="text-align: center">{$item["uid"]}</td>
                            <td>{$item["username"]}</td>
                            <td>{php echo date('Y-m-d H:i:s',$item["joindate"])}</td>
                            <td>￥{$item["credit2"]}</td>
                            <td style="text-align: right">
                                <div class="btn-group text-left">
                                    <a class="btn btn-default btn-sm" href="{php echo $this->createWebUrl('Users',array('op'=>'cz','uid'=>$item[uid]))}" title="充值记录"><i class="fa fa-share"></i>充值记录</a>
                                    <a class="btn btn-default btn-sm" href="{php echo $this->createWebUrl('Users',array('op'=>'xf','uid'=>$item[uid]))}" title="消费记录"><i class="fa fa-share"></i>消费记录</a>
                                    <a data-uid="{$item[uid]}" class="btn btn-default btn-sm" data-toggle="modal" data-target="#myModal"><i class="fa fa-edit"></i>金钱操作</a>
                                </div>
                            </td>
                        </tr>
                        {/loop}
                        </tbody>
                    </table>
                    <div style="margin: 10px">{$pager}</div>
                </div>
            </section>
        </aside>
    </div>
</div>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="top: 25%">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">用户币操作</h4>
            </div>
            <div class="modal-body">
                <div class="panel-body" style="margin: 15px">
                    <form action="" class="form-horizontal form" id="form_1" method="post" enctype="multipart/form-data">
                        <div class="form-group">
                            <label class="col-sm-2"></label>
                            <div class="col-sm-8">
                                <div class="input-group" >
                                    <span class="input-group-addon">交易币</span>
                                    <input class="form-control" name="credit2" type="text" placeholder="正数为加，负数为减" value="" >
                                </div>
                            </div>
                            <label class="col-sm-2"></label>
                            <input type="hidden" name="uid"/>
                        </div>
                    </form>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-warning btn-submit">提交</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<script language='javascript'>
    require(['jquery', 'util'], function($, u){
        $('#myModal').on('show.bs.modal', function (event) {
            var button = $(event.relatedTarget) // Button that triggered the modal
            var uid = button.data('uid') // Extract info from data-* attributes
            // If necessary, you could initiate an AJAX request here (and then do the updating in a callback).
            // Update the modal's content. We'll use jQuery here, but you could use a data binding library or other methods instead.
            var modal = $(this)
            modal.find('input[name=uid]').val(uid);
            modal.find('button.btn-submit').on("click",function(){
                $(this).attr("disabled","true");
                $.ajax({
                    'url':"{php echo $this->createWebUrl('users')}",
                    'data':$("form").serialize(),
                    'type':'POST',
                    'async':'true',
                    'dataType':'json',
                    'complete':function(XMLHttpRequest, textStatus){
                        $("button.btn-submit").removeAttr("disabled");
                    },
                    'success':function(data){
                        console.debug(data);
                        alert(data.message);
                        if(data.code>0){
                            location.reload();
                        }
                    }
                });
            });
        })
    });
</script>
{/if}
{template 'common/footer'}